package com.fypWebService;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.Hashtable;

import javax.jms.Connection;
import javax.jms.Destination;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageConsumer;
import javax.jms.MessageProducer;
import javax.jms.Queue;
import javax.jms.QueueConnection;
import javax.jms.QueueConnectionFactory;
import javax.jms.QueueReceiver;
import javax.jms.QueueSender;
import javax.jms.QueueSession;
import javax.jms.Session;
import javax.jms.TextMessage;
import javax.jws.WebService;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.*;


/**
 * Servlet implementation class FundTransfer
 */

public class FundTransfer extends HttpServlet {
	private static final long serialVersionUID = 1L;
	 
     
    /**
     * @see HttpServlet#HttpServlet()
     */
    public FundTransfer() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		
		
		RequestDispatcher dispatcher = request.getRequestDispatcher("/FundTransfer.jsp");
		if (dispatcher != null) dispatcher.forward(request, response);
		
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		String accountNumber = request.getParameter("accountNumber");
		String amount = request.getParameter("amount");
		
		System.out.println("Account Number: "+accountNumber);
		System.out.println("Amount:         "+amount);
		
		RBKClientService rbkcs = new RBKClientService();
		
		rbkcs.sendRequestRBK("00|02|"+accountNumber+"|"+amount);
		RequestDispatcher dispatcher = request.getRequestDispatcher("/FundTransfer.jsp");
		if (dispatcher != null) dispatcher.forward(request, response);
	}


}
